#！/bin/bash
source /etc/profile
if [ -n "$1" ]
then
  do_date=$1
else
  do_date=`date -d "-1 day" +%F`
fi
sql="
insert overwrite table ads.ads_trade_order_analysis_day
partition(dt='$do_date')
select count(*) ordercount,
   sum(pay_money) totalmoney,
      Quarter(dt) as quarter,
      MONTH(dt) as month,
      WEEK(dt, 1) as week;
from dws.dws_trade_orders
where dt = '$do_date'
"
hive -e "$sql"